#include <stdio.h>
#include <stdlib.h>

typedef int TElemSet;
typedef struct TreeNode *Position;
typedef struct TreeNode *Tree;
struct TreeNode {
    TElemSet data; /* 数据元素 */
    Tree first_child; /* 第一个子结点 */
    Tree next_sibling; /* 下一个兄弟结点 */
};

/* 算法5-18：查找树中带有指定数据的结点 Search(tree, x) */
Position Search(Tree tree, TElemSet x) {
    Tree node_ptr;

    node_ptr = tree;
    if (node_ptr != NULL) {
        if (node_ptr->data != x) {
            node_ptr = Search(tree->first_child, x); /* 在子孙结点中查找 */
            if (node_ptr == NULL) { /* 不在子孙结点中 */
                node_ptr = Search(tree->next_sibling,
                                  x); /* 在兄弟结点及其子孙中找 */
            }
        }
    }
    return node_ptr;
}
/* 算法5-18 结束 */

Tree NewTreeNode() {
    Tree node_ptr;

    node_ptr = (Tree)malloc(sizeof(struct TreeNode));
    scanf("%d", &node_ptr->data);
    node_ptr->first_child = NULL;
    node_ptr->next_sibling = NULL;
    return node_ptr;
}

int main(void) {
    Tree tree, child, sibling, p;
    TElemSet x;

    tree = NewTreeNode();
    child = NewTreeNode();
    sibling = NewTreeNode();
    tree->first_child = child;
    child->next_sibling = sibling;
    sibling->next_sibling = NewTreeNode();
    scanf("%d", &x);
    p = Search(tree, x);
    if (p != NULL) {
        printf("%d is found.\n", p->data);
    } else {
        printf("%d is NOT found.\n", x);
    }

    return 0;
}